import { IsNotEmpty, Matches } from 'class-validator'
import { Unique } from '../../validate/unique'

export class RegisterDto {
	@IsNotEmpty({ message: '昵称不能为空' })
	nickname: string

	@IsNotEmpty({ message: '用户名不能为空' })
	@Matches(/^[a-zA-Z0-9.@]{3,20}$/, { message: '用户名格式错误, 且长度在3-20个字符' })
	@Unique('user', ['username', 'email', 'mobile'], { message: '用户名已存在' })
	username: string

	@IsNotEmpty({ message: '密码不能为空' })
	@Matches(/^[a-zA-Z0-9,.!@#]{6,20}$/, { message: '密码格式错误, 且长度在6-20个字符' })
	password: string
}
